/******************************************************************************/
/*  Class MLOG                                                                */
/*  PO: S. Maslyakov, rusoil.9@gmail.com                                      */
/*                                                                            */
/*  Revision:     1.0                                                         */
/*  Date:         2011/03/26 22:24:33                                         */
/******************************************************************************/


#ifndef __MLOG_H
#define __MLOG_H


#include "Mlog\mlog_def.h"


//==============================================================================
//  Class MLOG
//==============================================================================
class MLOG
{
public:
  static void Init_Mlog();
  static void * GetPntrLog(const uint32_t _index);
  static void Init_mlog_tasks();
  static void Activate_mlog_task();

private:
  static void InitLogs();
  static void MakeRec(const uint32_t _log_ind, const uint16_t _event);
  static void Create_dque();
  static void Task_mlog_timer(void * par);
  static void Task_mlog_write(void * par);
  static void Task_mlog_send(void * par);
  static void SetLogSendState(const uint32_t _index);
  static void ClearLogSendState(const uint32_t _index);
  static bool_t GetLogSendState(const uint32_t _index);

  static uint32_t ReadParamSett(const uint32_t _logInd,
                                uint8_t * const _pParamSett);
  static uint32_t ReadRec(const uint32_t _logInd,
                          const uint32_t _recNum,
                          uint8_t * const _pRec);
  static sint32_t SendData(const void * const _pData);
  static sint32_t Connect();
  static sint32_t Disconnect();
  static sint32_t AddHeader(int8_t * const _pBuff);
  static sint32_t AddEnd(int8_t * const _pBuff);
  static sint32_t AddHeaderRec(int8_t * const _pBuff, const void * _pHeader);
  static sint32_t AddParam(int8_t * const _pBuff,
                           const uint32_t _param,
                           const uint32_t _dev_id,
                           const uint16_t _id,
                           const uint8_t _type);
  static sint32_t AddRecEnd(int8_t * const _pBuff);
  static uint32_t MakePacket(const uint32_t _logInd);

  static uint32_t m_flgSendState;
  static uint32_t m_timer[MLOG_QNT_LOGS - 1];
};
//==============================================================================
//==============================================================================



#endif